#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>

typedef char BTDataType;

typedef struct BinaryTreeNode
{
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
    BTDataType data;
}BTNode;

BTNode* BuyNode(BTDataType x)
{
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
    if (newnode == NULL)
    {
        perror("malloc");
        exit(-1);
    }
    newnode->data = x;
    newnode->left = NULL;
    newnode->right = NULL;
    return newnode;
}

BTNode* CreateTree(char* str, int* pi)
{
    if (str[*pi] == '\0')
    {
        return NULL;
    }
    if (str[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    BTNode* root = BuyNode(str[(*pi)++]);
    root->left = CreateTree(str, pi);
    root->right = CreateTree(str, pi);
    return root;
}

void InOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->data);
    InOrder(root->right);
}

int main()
{
    char str[100] = { 0 };
    while (scanf("%s", str) != EOF)
    {
        int i = 0;
        BTNode* root = CreateTree(str, &i);
        InOrder(root);
    }
    return 0;
}